import torch
import torch.nn as nn
import math
a = torch.Tensor([1, 2, 3])
# 定义Softmax
softmax = nn.Softmax(dim=0)
data=softmax(a)
print(data)
# 输出：tensor([0.0900, 0.2447, 0.6652])
print("log处理后",[math.log(x) for x in data.numpy()])
# 定义LogSoftmax
lsm_a = nn.LogSoftmax(dim=0)(a)
print("系统自带的函数",lsm_a)
# 输出tensor([-2.4076, -1.4076, -0.4076])，其中ln(0.0900)=-2.4076
